﻿using System;
using System.Collections.Generic;
using UnityEngine;

public class UIComponentMastermind : MonoBehaviour
{
    public static UIComponentMastermind instance;
    public Action<string> Func_InputOK;
    public Action Func_InputCancel;
    public Action Func_Yes;
    public Action Func_No;

    [SerializeField]
    public ColorPalatteComponent m_ColorPalatteComponent;

    [SerializeField]
    Transform m_InputTransform;
    [SerializeField]
    Transform m_YesOrNoTransform;

    [SerializeField]
    UILabel m_InputLabel;
    [SerializeField]
    UILabel m_YesOrNoTitleLabel;


    [SerializeField]
    UIButton m_LeftUITransform;
    UIToggle m_LeftUITransformUIToggle;

    [SerializeField]
    UIButton m_RightUITransform;
    UIToggle m_RightUITransformUIToggle;

    void Awake()
    {
        instance = this;
        m_RightUITransformUIToggle = m_RightUITransform.GetComponent<UIToggle>();
        m_LeftUITransformUIToggle = m_LeftUITransform.GetComponent<UIToggle>();

        EventDelegate.Add(m_LeftUITransform.onClick,() => {
            if (m_RightUITransformUIToggle)
            {
                if (!m_RightUITransformUIToggle.value)
                {
                    m_RightUITransformUIToggle.value = true;
                }
            }
        });

        EventDelegate.Add(m_RightUITransform.onClick, () => {
            if (m_LeftUITransformUIToggle)
            {
                if (!m_LeftUITransformUIToggle.value)
                {
                    m_LeftUITransformUIToggle.value = true;
                    VoxelEditorMastermind.instance.SelectOperationBehaviorTransform();
                }
            }
        });

    }

    public void ShowInput(string title , Action<string> Func_InputOK, Action Func_InputCancel)
    {
        m_InputTransform.gameObject.SetActive(true);
        this.m_InputLabel.text = title;
        this.Func_InputOK = Func_InputOK;
        this.Func_InputCancel = Func_InputCancel;
    }


    public void ShowYesOrNo(string title, Action Func_Yes, Action Func_No)
    {
        m_YesOrNoTransform.gameObject.SetActive(true);
        this.m_YesOrNoTitleLabel.text = title;
        this.Func_Yes = Func_Yes;
        this.Func_No = Func_No;
    }

    public void ShowLeftUITransform()
    {
        EventDelegate.Execute(m_LeftUITransform.onClick);
        if (m_LeftUITransformUIToggle)
        {
            if (!m_LeftUITransformUIToggle.value)
            {
                m_LeftUITransformUIToggle.value = true;
            }
        }
    }

    public void ShowRightUITransform()
    {
        EventDelegate.Execute(m_RightUITransform.onClick);
        if (m_RightUITransformUIToggle)
        {
            if (!m_RightUITransformUIToggle.value)
            {
                m_RightUITransformUIToggle.value = true;
            }
        }
    }

    void Start () {
		
	}
	

	void Update () {
		
	}
}
